﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="User_Manage.aspx.cs" Inherits="Catering.Catering_Page.system.User_Manage" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../../Style/center.css" rel="stylesheet" type="text/css" />
    <link href="../../Style/zhezhao.css" rel="stylesheet" type="text/css" />
    <script src="../../Style/zhezhao.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <style type="text/css">
        *{margin:0px; padding:0px;}
        .search_title{background-color:#e5f1ff; height:34px; border:1px solid #c2def6;margin-top:0px;}
        .main{margin-top:10px;}
        .table_title{ background:url(../../Images/table_th_bg.gif) repeat-x 0px 0px;height:32px;}
        .Page{width:300px;margin:10px auto 0px auto;}
        body{ font-size:12px;}
        .table_120 td{padding:5px 0px;}
        .data_css{width:788px;margin-top:10px; border:#ccc 1px solid;}
        .data_css th{ background:url(../../Images/th_02bg.gif) repeat-x 0px 0px;padding:0px; text-align:center;height:29px; border-right:#ccc 1px solid; font-weight:400;}
        .data_css td{ text-align:center; height:26px; line-height:26px; border-bottom:1px dashed #ccc}
        .data_css td a{color:#000000; text-decoration:none;}
    </style>
    <script type="text/javascript">
        //添加用户
        function ShowAdd(uid) {
            $("#HidRid").val(uid);
            
            $.ajax({
                type: "Post",
                url: "User_Manage.aspx/GetPersonnel",
                data: "{'uid':'" + uid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#txt_username").val("");
                    $("#txt_password").val("");
                    $("#txt_password2").val("");
                    $("#tr_password").show();
                    $("#tr_password2").show();
                    $("#txt_QQ").val(data.d[0]);
                    $("#txt_tel").val(data.d[1]);
                    $("#txt_Email").val(data.d[2]);
                    $("#btn_Add").show();
                    $("#btn_Edit").hide();
                    $("#HidIsEdit").val("Add");
                    divshow("user_main", "bg");
                }
            });
        }

        function YanZheng() {
            var password = $("#txt_password").val();
            var password2 = $("#txt_password2").val();
            if (password != password2) {
                alert("两次密码不一致！");
                return false;
            }
        }

        function Edut_YanZheng() {
            var password = $("#txt_Editpassword").val();
            var password2 = $("#txt_Editpassword2").val();
            if (password != password2) {
                alert("两次密码不一致！");
                return false;
            }
            return true;
        }

        //修改用户
        function ShowEdit(uid) {
            $.ajax({
                type: "Post",
                url: "User_Manage.aspx/GetUser",
                data: "{'uid':'" + uid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#txt_username").val(data.d[0]);
                    $("#txt_password").val(data.d[1]);
                    $("#txt_password2").val(data.d[1]);
                    $("#tr_password").hide();
                    $("#tr_password2").hide();
                    $("#Drop_Role").val(data.d[2]);
                    $("#txt_QQ").val(data.d[3]);
                    $("#txt_tel").val(data.d[4]);
                    $("#txt_Email").val(data.d[5]);
                    $("#HidRid").val(data.d[6]);
                    $("#btn_Add").hide();
                    $("#btn_Edit").show();
                    $("#HidIsEdit").val("Edit");
                    divshow("user_main", "bg");
                }
            });
        }

        //显示修改密码
        function ShowEditPassWord(uid) {
            $("#HidRid").val(uid);
            $.ajax({
                type: "Post",
                url: "User_Manage.aspx/GetUser",
                data: "{'uid':'" + uid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#span_uname").text(data.d[0]);
                    $("#HidRid").val(data.d[6]);
                    divshow("user_password", "bg");
                }
            });
        }


        //控制控件是否可用
        function EnableBtn(istrue) {
            if ($("#HidIsEdit").val() == "Edit") {
                if (istrue) {
                    $("#btn_Edit").removeAttr("disabled");
                }
                else { 
                    $("#btn_Edit").attr("disabled", "disabled");
                }
                
            }
            else {
                if (istrue) {
                    $("#btn_Add").removeAttr("disabled");
                }
                else {
                    $("#btn_Add").attr("disabled", "disabled");
                }
            }
        }

        $(document).ready(function () {
            $("#txt_username").focusout(function () {
                var uname = $(this).val();
                var IsAdd = $("#HidIsEdit").val();
                var uid = $("#HidRid").val();

                if (uname == "") {
                    alert("用户名不能为空！");
                    EnableBtn(false);
                }

                $.ajax({
                    type: "Post",
                    url: "User_Manage.aspx/UserIsExts",
                    data: "{'uname':'" + uname + "','IsAdd':'" + IsAdd + "','uid':'" + uid + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        if (data.d[0] == "NO") {
                            alert("该用户名已存在！");
                            EnableBtn(false);
                        }
                        else {
                            EnableBtn(true);
                        }
                    }
                });


            });
        });

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="HidRid" runat="server" />
    <asp:HiddenField ID="HidIsEdit" runat="server" />
    <div class="layout" style="overflow-y:auto; height:380px; margin:0px; padding:0px; ">
        <div style="height:36px; line-height:36px; font-size:13px;">&nbsp;当前位置：用户管理</div>
        <div class="search_title">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td height="34" width="75" align="right">作业区：</td>
                    <td width="100"><asp:DropDownList ID="Drop_zuoyequ" runat="server" Width="90" CssClass="select_input_bg" 
                            onselectedindexchanged="Drop_zuoyequ_SelectedIndexChanged" AutoPostBack="true" ></asp:DropDownList>
                    </td>
                    <td width="45" align="right">班组：</td>
                    <td width="100"><asp:DropDownList ID="Drop_banzu" runat="server" CssClass="select_input_bg" Width="90" ></asp:DropDownList></td>
                    <td width="45" align="right">名称：</td>
                    <td width="100"><asp:TextBox ID="txt_name" runat="server" CssClass="input_bg" Width="80"></asp:TextBox></td>
                    <td><asp:Button ID="btn_Search" runat="server" CssClass="input_btn_a" Text="查询" onclick="btn_Search_Click"/></td>
                </tr>
            </table>
        </div>
        <div>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="data_css">
                <thead>
                    <tr>
                        <th width="8%">姓名</th>
                        <th width="6%">性别</th>
                        <th width="6%">年龄</th>
                        <th width="10%">身份证号</th>
                        <th width="10%">QQ</th>
                        <th width="10%">手机</th>
                        <th width="10%">账号</th>
                        <th width="10%">班组</th>
                        <th width="10%">岗位</th>
                        <th width="20%">操作</th>
                    </tr>
                </thead>
                <tbody>
                    <asp:Repeater ID="Rep_Personnel" runat="server">
                        <ItemTemplate>
                            <tr>
                                <td align="center"><%#Eval("Name")%></td>
                                <td align="center"><%#Eval("Sex")%></td>
                                <td align="center"><%#this.GetOldByDate(Eval("Old").ToString())%></td>
                                <td><%#Eval("No")%>&nbsp;</td>
                                <td><%#Eval("QQ")%>&nbsp;</td>
                                <td><%#Eval("Tel")%>&nbsp;</td>
                                <td><%#this.GetPersonnelInfo(Eval("id").ToString())%>&nbsp;</td>
                                <td><%#this.GetClassName(Eval("ClassID") == null ? "" : Eval("ClassID").ToString())%></td>
                                <td align="center"><%#this.GetBranchPost(Eval("PID").ToString())%></td>
                                <td><%#this.IsExistsUser(Eval("id").ToString())%></td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </tbody>
            </table>
        </div>
        <div class="Page">
            <webdiyer:aspnetpager id="AspNetPager1" runat="server" pagesize="10" onpagechanging="AspNetPager1_PageChanging"
             firstpagetext="首页" lastpagetext="尾页" nextpagetext="下一页" prevpagetext="上一页" showpageindex="true">
            </webdiyer:aspnetpager>
        </div>
    </div>
    <!--遮罩-->
    <div id="bg" class="bg"></div>
    <div id="user_main" class="center_div table_120" style="margin-top:-100px;padding:10px 10px;width:230px;">
        <table border="0" cellpadding="0" cellspacing="0" style="width:100%;">
            <tbody>
                <tr>
                    <td width="60" align="right">账号：</td>
                    <td><asp:TextBox ID="txt_username" runat="server" CssClass="input_bg" Width="150"></asp:TextBox></td>
                </tr>
                <tr id="tr_password">
                    <td align="right">密码：</td>
                    <td><asp:TextBox ID="txt_password" TextMode="Password" runat="server" Width="150" CssClass="input_bg"></asp:TextBox></td>
                </tr>
                <tr id="tr_password2">
                    <td align="right">确认密码：</td>
                    <td><asp:TextBox ID="txt_password2" TextMode="Password" runat="server" Width="150" CssClass="input_bg"></asp:TextBox></td>
                </tr>
                <tr>
                    <td align="right">角色：</td>
                    <td><asp:DropDownList ID="Drop_Role" runat="server" CssClass="select_input_bg" Width="152"></asp:DropDownList></td>
                </tr>
                <tr>
                    <td align="right">QQ：</td>
                    <td><asp:TextBox ID="txt_QQ" runat="server" CssClass="input_bg" Width="150"></asp:TextBox></td>
                </tr>
                <tr>
                    <td align="right">手机：</td>
                    <td><asp:TextBox ID="txt_tel" runat="server" CssClass="input_bg" Width="150"></asp:TextBox></td>
                </tr>
                <tr>
                    <td align="right">邮箱：</td>
                    <td><asp:TextBox ID="txt_Email" runat="server" CssClass="input_bg" Width="150"></asp:TextBox></td>
                </tr>
            </tbody>
        </table>
        <table border="0" cellpadding="0" cellspacing="0" style="width:100%;">
            <tr>
                <td align="center">
                        <asp:Button ID="btn_Add" runat="server" OnClick="btn_Add_Click" Text="提交"  CssClass="input_btn_a" />
                        <asp:Button ID="btn_Edit" runat="server" OnClick="btn_Edit_Click" Text="提交" CssClass="input_btn_a" />
                    </td>
                    <td align="center">
                        <input type="button" id="btn_quxiao" onclick='divhidel("user_main", "bg")' value="取消" class="input_btn_a" />
                    </td>
            </tr>
        </table>
    </div>
    <div id="user_password" class="center_div table_120" style="margin-top:-100px;padding:10px 10px;width:230px;">
        <table border="0" cellpadding="0" cellspacing="0" style="width:100%;">
            <tbody>
                <tr>
                    <td width="75" align="right">账    号：</td>
                    <td><span id="span_uname"></span></td>
                </tr>
                <tr>
                    <td align="right">密　　码：</td>
                    <td><asp:TextBox ID="txt_Editpassword" TextMode="Password" runat="server" CssClass="input_bg" Width="150"></asp:TextBox></td>
                </tr>
                <tr>
                    <td align="right">确认密码：</td>
                    <td><asp:TextBox ID="txt_Editpassword2" TextMode="Password" runat="server" CssClass="input_bg" Width="150"></asp:TextBox></td>
                </tr>
            </tbody>
        </table>
        <table border="0" cellpadding="0" cellspacing="0" style="width:100%;">
            <tr>
                <td align="center">
                        <asp:Button ID="btn_EditPassWord" runat="server" OnClick="btn_EditPassWord_Click" Text="提交"  CssClass="input_btn_a" />
                    </td>
                    <td align="center">
                        <input type="button" id="Button3" onclick='divhidel("user_password", "bg")' value="取消" class="input_btn_a" />
                    </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
